<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/11/23
 * Time: 09:14
 */

namespace app\modules\composite\controller;

use app\modules\composite\Form;
use app\modules\composite\InputElement;
use app\modules\composite\TextElement;
use yii\web\Controller;

class DefaultController extends Controller
{
    /**
     * 组合模式示例
     * 一组对象与该对象的单个实例的处理方式一致。
     *
     * @date   2018/11/24
     * @author edmmss
     * @return bool
     */
    public function actionIndex()
    {
        $form = new Form();
        $formBak = new Form();
        $textElement = new TextElement('测试的text');
        $inputElement = new InputElement();

        $form->addElement($textElement);
        $form->addElement($inputElement);

//        $formBak->addElement($textElement);
//        $formBak->addElement($inputElement);
//
//        $form->addElement($formBak);
        $html = $form->render();
        var_dump($html);

        return true;
    }
}